package pkgCron

import (
	"fmt"
	cron1 "github.com/robfig/cron/v3"
	"sync"
)

var once sync.Once

var Cron *cron1.Cron

func init() {
	once.Do(func() {
		Cron = cron1.New()
	})
}

func  AddFunc(spec string, job func()) (cron1.EntryID,error) {

	JobId, err := Cron.AddFunc(spec,job)
	Cron.Start()
	if err != nil {
		return 0, err
	}

	return  JobId,nil
}


func  DelFunc(id int) {
	var eid cron1.EntryID
	eid = cron1.EntryID(id)
	Cron.Remove(eid)
}

func Ed(id int)  {
	cc := Cron.Entry(cron1.EntryID(id))
	fmt.Println(cc)
}